<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function getRobotAnswer(userid, question) {
	var deferred = $.Deferred();
	$.ajax({
		type: "post",
		//url: 'http://ibotcluster.uniginrobot.com/robot/app/tt1/ask.action',
		url: 'http://223.71.57.70:10000/robot/app/hdgsfj/ask.action',
		data: {
			userId: userid,
			question: question,
			platform: 'web',
			format: 'json',
		},
		dataType: "jsonp", //数据格式设置为jsonp
		jsonp: "callback", //Jquery生成验证参数的名称
		success: function(data) {
			deferred.resolve(data);
			alert(JSON.stringify(data));
		},
		error: function() {
			deferred.reject();
		}
	});

	return deferred.promise();
}

function getAnswer(userid, question) {
	if(question) {
		$.when(getRobotAnswer(question)).done(function(data) {
			appendRobotContent(data.content, true);
			if(data.commands) {
				var commands = data.commands;
				for(var i = 0; i < commands.length; i++) {
					var command = commands[i];
					console.log(command);
				}
			}
		}).fail(function() {
			appendRobotContent('网络中断', true)
		});
	}
}
</script>
</head>

<body>
<input type="button" value="问" onclick="getRobotAnswer('litong','今天天气怎么样')" />
</body>

</html>